package logic

import (
	"car_srv/models"
	"context"

	"car_srv/car"
	"car_srv/internal/svc"

	"github.com/zeromicro/go-zero/core/logx"
)

type GoodsUpdateStatusLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewGoodsUpdateStatusLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GoodsUpdateStatusLogic {
	return &GoodsUpdateStatusLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

// 商品审核
func (l *GoodsUpdateStatusLogic) GoodsUpdateStatus(in *car.GoodsUpdateStatusRequest) (*car.GoodsUpdateStatusResponse, error) {
	var good models.Good
	good.ID = uint(in.Id)
	good.Status = in.Status
	if err := good.UpdateStatus(); err != nil {
		logx.Error("审核商品失败", err)
		return nil, err
	}

	return &car.GoodsUpdateStatusResponse{
		Id: int64(good.ID),
	}, nil
}
